//定义懒加载插件
import { useIntersectionObserver } from '@vueuse/core'
export const lazyPlugin = {
    install(app) {
        //懒加载指令逻辑
        //定义全局指令
        app.directive('img-lazy', {
            mounted(el, binding) {
                //el:指令所在的元素
                //binding:指令的参数
                console.log(el, binding.value)
                const {stop} =useIntersectionObserver(el, ([{ isIntersecting }]) => {
                    if (isIntersecting) {
                        el.src = binding.value
                        stop()
                    }
                },
                )
            }
        })
    }
}